﻿<r:RibbonWindow 
    x:Class="Sniffer.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:me="clr-namespace:Sniffer"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:basic="clr-namespace:Sniffer"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Background="{DynamicResource WindowBackground}"
    WindowStartupLocation="CenterScreen"
    Title="Sniffer" Height="600" Width="800">

    <r:RibbonWindow.Resources>
        <ResourceDictionary>
            <!-- Uncomment below for Office 2007 Blue -->
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <LinearGradientBrush x:Key="dgHeaderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Color="#FF6B8E95" Offset="0"/>
                <GradientStop Color="#FF14A7C1" Offset="1"/>
                <GradientStop Color="#FF1E424E" Offset="0.509"/>
                <GradientStop Color="#FF1D4855" Offset="0.542"/>
                <GradientStop Color="#FF1D4855" Offset="0.542"/>
                <GradientStop Color="#FF193A44" Offset="0.526"/>
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="dgHeaderBorderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Color="#FF1D1D1D" Offset="0.614"/>
                <GradientStop Color="#FF007F96" Offset="0.853"/>
                <GradientStop Color="#FF0AEAFA" Offset="1"/>
            </LinearGradientBrush>

            <Style x:Key="dgHeaderStyle" TargetType="GridViewColumnHeader">
                <Setter Property="Background" Value="{StaticResource dgHeaderBrush}" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="BorderBrush" Value="{StaticResource dgHeaderBorderBrush}" />
            </Style>

            <Style x:Key="dgRowStyle" TargetType="ListViewItem">
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Background" Value="White" />
                <Style.Triggers>
                    <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                        <Setter Property="Background" Value="#FFD0D0E0" />
                    </Trigger>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Background" Value="DarkSeaGreen" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            <ImageBrush x:Key="WindowBackground" Stretch="Fill" 
                    ImageSource="Images/Wave.jpg" />
        </ResourceDictionary>
    </r:RibbonWindow.Resources>
    <!-- Command bindings -->
    <r:RibbonWindow.CommandBindings>
        <CommandBinding Command="me:AppCommands.Help" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.Stop" CanExecute="CanStopListening" Executed="StopListening" />
        <CommandBinding Command="me:AppCommands.Start" CanExecute="CanStartListening" Executed="StartListening" />
        <CommandBinding Command="me:AppCommands.SetFilter" Executed="SetFilter" />
        <CommandBinding Command="me:AppCommands.FindInterfaces" Executed="FindInterfaces" />
        <CommandBinding Command="me:AppCommands.GoToFirstPacket" CanExecute="CanGoToFirstPacketExecute" Executed="GoToFirstPacket" />
        <CommandBinding Command="me:AppCommands.GoToLastPacket" CanExecute="CanGoToLastPacketExecute"  Executed="GoToLastPacket" />
        <CommandBinding Command="me:AppCommands.GoToPacket" CanExecute="CanGoToLastPacketExecute"  Executed="GoToPacket" />
        <CommandBinding Command="me:AppCommands.Open" CanExecute="CanOpenExecute"  Executed="OnOpenFile" />
        <CommandBinding Command="me:AppCommands.Save" CanExecute="CanSaveExecute"  Executed="OnSaveFile" />
        <CommandBinding Command="me:AppCommands.ClearBoard" CanExecute="CanGoToFirstPacketExecute"  Executed="ClearBoard_Executed" />
    </r:RibbonWindow.CommandBindings>

    <Viewbox Stretch="Fill">
        <Canvas Height="600" Width="800" x:Name="LayoutRoot">
            <DockPanel Canvas.Left="0" Canvas.Top="0">
                <r:Ribbon DockPanel.Dock="Top" Height="119.851" Width="799.285"  FocusManager.IsFocusScope="True" Title="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=Title}">
                    <r:Ribbon.Resources>
                        <r:RibbonGroupSizeDefinitionCollection x:Key="RibbonLayout">
                            <r:RibbonGroupSizeDefinition>
                                <!-- Control sizes: L,L,L -->
                                <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                                <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                                <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                            </r:RibbonGroupSizeDefinition>
                            <r:RibbonGroupSizeDefinition>
                                <!-- Control sizes: L,M,M -->
                                <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                                <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                                <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                            </r:RibbonGroupSizeDefinition>
                            <r:RibbonGroupSizeDefinition>
                                <!-- Control sizes: L,S,S -->
                                <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                                <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False"/>
                                <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False"/>
                            </r:RibbonGroupSizeDefinition>
                            <!-- Collapsed -->
                            <r:RibbonGroupSizeDefinition IsCollapsed="True" />
                        </r:RibbonGroupSizeDefinitionCollection>
                    </r:Ribbon.Resources>
                    <r:RibbonTab Label="File">
                        <r:RibbonTab.Groups>
                            <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}" Height="70" HorizontalAlignment="Center" VerticalAlignment="Top">
                                <r:RibbonGroup.Command>
                                    <r:RibbonCommand LabelTitle="File Board"/>
                                </r:RibbonGroup.Command>
                                <r:RibbonButton Command="me:AppCommands.Open" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.Save" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.ClearBoard" Height="55"/>
                            </r:RibbonGroup>

                        </r:RibbonTab.Groups>
                    </r:RibbonTab>
                    <r:RibbonTab Label="Capture">
                        <r:RibbonTab.Groups>
                            <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}" Height="70" HorizontalAlignment="Center" VerticalAlignment="Top">
                                <r:RibbonGroup.Command>
                                    <r:RibbonCommand LabelTitle="Operation board" />
                                </r:RibbonGroup.Command>
                                <r:RibbonButton Command="me:AppCommands.Start" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.Stop" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.FindInterfaces" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.SetFilter" Height="55"/>
                            </r:RibbonGroup>
                        </r:RibbonTab.Groups>
                    </r:RibbonTab>
                    <r:RibbonTab Label="Go">
                        <r:RibbonTab.Groups>
                            <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}" Height="70" HorizontalAlignment="Center" VerticalAlignment="Top">
                                <r:RibbonGroup.Command>
                                    <r:RibbonCommand LabelTitle="go board"/>
                                </r:RibbonGroup.Command>
                                <r:RibbonButton Command="me:AppCommands.GoToFirstPacket" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.GoToLastPacket" Height="55"/>
                                <r:RibbonButton Command="me:AppCommands.GoToPacket" Height="55"/>
                            </r:RibbonGroup>
                        </r:RibbonTab.Groups>
                    </r:RibbonTab>
                    <r:RibbonTab Label="Help">
                        <r:RibbonTab.Groups>
                            <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}" Height="70" HorizontalAlignment="Left" VerticalAlignment="Top">
                                <r:RibbonGroup.Command>
                                    <r:RibbonCommand LabelTitle="About Sniffer"/>
                                </r:RibbonGroup.Command>
                                <r:RibbonButton Command="me:AppCommands.Help" Height="55" HorizontalAlignment="Center"/>
                            </r:RibbonGroup>
                        </r:RibbonTab.Groups>
                    </r:RibbonTab>
                    <r:Ribbon.ApplicationMenu>
                        <r:RibbonApplicationMenu Visibility="Hidden">
                        </r:RibbonApplicationMenu>
                    </r:Ribbon.ApplicationMenu>
                </r:Ribbon>
            </DockPanel>

            <Border Canvas.Left="0" Canvas.Top="123.851" Width="800" Height="202.149" BorderThickness="1" BorderBrush="Black">
                <ListView x:Name="ViewBody" Background="#80909090" SelectionChanged="ViewBody_SelectionChanged" AlternationCount="2" ItemContainerStyle="{StaticResource dgRowStyle}" Canvas.Left="0" Canvas.Top="123.851" Width="800" Height="202.149" >
                    <ListView.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                            <Setter Property="MinWidth" Value="50" />
                            <Setter Property="Background" Value="Transparent" />
                        </Style>
                    </ListView.Resources>
                    <ListView.View>
                        <GridView ColumnHeaderContainerStyle="{StaticResource dgHeaderStyle}">
                            <GridView.Columns>
                                <GridViewColumn Header="No." Width="50">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetNo,Mode=OneWay}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Time" Width="100">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetcurTime,Mode=OneWay}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Source" Width="200">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetSource,Mode=OneWay}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Destination" Width="200">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetDestination,Mode=OneWay}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Protocol" Width="100">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetprotocol,Mode=OneWay}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Length" Width="60">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding packetlength,Mode=OneWay}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <!--<GridViewColumn Header="Info" Width="300">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding packetInfo,Mode=OneWay}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>-->
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Border>
            <Border Canvas.Left="0" Canvas.Top="331" BorderThickness="1" BorderBrush="Black" Height="150" Width="800">
                <Grid Background="White" Canvas.Left="0" Canvas.Top="332" Height="150" Width="800">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <Grid Grid.Column="0">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <ScrollViewer x:Name="scrolls" PreviewMouseWheel="scrolls_MouseWheel" Margin="0,0,0,0" Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                            <ScrollViewer.Content>
                                <StackPanel x:Name="TreeViewStack" Margin="0,0,0,0" Grid.Row="0">
                                    <!--<basic:InfoTreeViewControl/>
                                <basic:InfoTreeViewControl/>-->
                                </StackPanel>
                            </ScrollViewer.Content>
                        </ScrollViewer>
                    </Grid>
                </Grid>
            </Border>
            
            <Border Canvas.Left="0" Canvas.Top="483" Height="2" Width="800" BorderThickness="1" BorderBrush="Black"/>
            <Border Canvas.Left="0" Canvas.Top="485" Height="115" Width="800" BorderThickness="1" BorderBrush="Black">
                <Grid Background="White" Canvas.Left="0" Canvas.Top="485" Height="115" Width="800">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ScrollViewer Margin="0,0,0,0" Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                        <StackPanel Margin="0,0,0,0">
                            <TextBox x:Name="ThirdBoard" FontFamily="Courier New"  IsReadOnly="True" BorderThickness="0"/>
                        </StackPanel>
                    </ScrollViewer>
                    <Border Grid.Row="1" BorderThickness="1" Height="32" BorderBrush="Black">
                        <Grid VerticalAlignment="Top">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="60"/>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="65"/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <Label Grid.Column="0" Content="Packets: " FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="60"/>
                            <Label Grid.Column="1" x:Name="TotalPackets" Content="" FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="80"/>
                            <Label Grid.Column="2" Content="Displayed: " FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="70"/>
                            <Label Grid.Column="3" x:Name="TotalDisplayed" Content="" FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="80"/>
                            <Label Grid.Column="4" Content="Droped: " FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="65"/>
                            <Label Grid.Column="5" Content="0" FontSize="12" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25" Margin="6,1.986,0,0" Width="80"/>
                        </Grid>
                    </Border>
                </Grid>
            </Border>
        </Canvas>
    </Viewbox>
</r:RibbonWindow>
